#include "EQPoisson.h"
#include "EQHeat.h"
#include "EQWave.h"
#include <time.h>
#include <iostream>
#include <cmath>

using namespace std;
int main(int argc, char const *argv[])
{
	// EQPoisson mypde;
	// f2v f = [](double x, double y){return 0.0;};
	// f2v f = [](double x, double y){return 2.0;};
	// mypde.set_f(f);
	// f1v bc_left, bc_top, bc_right, bc_bottom;
	// bc_left = [](double y){return 0.0;};
	// bc_top = [](double x){return x;};
	// bc_right = [](double y){return y;};
	// bc_bottom = [](double x){return 0.0;};
	// bc_left = [](double y){return 0.0;};
	// bc_top = [](double x){return x + x*x;};
	// bc_right = [](double y){return 1+y;};
	// bc_bottom = [](double x){return x*x;};
	// mypde.set_BC_left(bc_bottom);
	// mypde.set_BC_top(bc_left);
	// mypde.set_BC_right(bc_top);
	// mypde.set_BC_bottom(bc_right);
	// mypde.set_xlimits(0,1);
	// mypde.set_ylimits(0,1);
	// // mypde.set_Nx(4);
	// // mypde.set_Ny(4);
	// mypde.set_eps(0.05,0.05);
	// clock_t start_time = clock();
	// // mypde.solve(GAUSS_SEIDEL);
	// mypde.solve(BLOCK_CYCLE_REDUCE);
	// clock_t end_time = clock();
	// std::cout << "Running time is: " << static_cast<double>(end_time - start_time)/CLOCKS_PER_SEC*1000 << "ms\n";
	// mypde.save_data("u.dat");
	// mypde.draw_data("u.eps");
	// clock_t start_time = clock();
	// EQHeat myheat;
	// f1v mbc_left, mbc_right, mic;
	// mbc_left = [](double t){return 0.0;};
	// mbc_right = [](double t){return 0.0;};
	// mic = [](double x){return 100.0;};
	// myheat.set_BC_left(mbc_left);
	// myheat.set_BC_right(mbc_right);
	// myheat.set_IC(mic);
	// myheat.set_a(0.1);
	// myheat.set_xlimits(0.0,1.0);
	// myheat.set_tlimits(0,1);
	// myheat.set_hx(0.001);
	// myheat.set_ht(0.001);
	// myheat.solve();
	// myheat.save_data("solution.txt");
	// std::vector<double> t_time(10);
	// t_time[0] = 0.0;
	// t_time[1] = 0.05;
	// t_time[2] = 0.10;
	// t_time[3] = 0.15;
	// t_time[4] = 0.2;
	// t_time[5] = 0.3;
	// t_time[6] = 0.4;
	// t_time[7] = 0.5;
	// t_time[8] = 0.6;
	// t_time[9] = 0.7;
	// myheat.draw_data("model.eps", t_time);
	// clock_t end_time = clock();
	// std::cout << "Running time is: " << static_cast<double>(end_time - start_time)/CLOCKS_PER_SEC*1000 << "ms\n";
	// clock_t start_time = clock();
	EQWave mywave;
	f1v mbc_left, mbc_right, myic1, myic2;
	mbc_left = [](double t){return 0.0;};
	mbc_right = [](double t){return 0.0;};
	// myic1 = [](double x){if((2/7.0 <= x) && (x <= 5/7.0)) return sin(14*asin(1.0)*x); else return 0.0;};
	// myic1 = [](double x){return sin(14*asin(1.0)*x);};
	//myic1 = [](double x){return sin(6*asin(1.0)*x);};
	myic1 = [](double x){if((3/7.0 <= x) && (x <= 4/7.0)) return 14*abs(x-0.5)-1; else return 0.0;};
	// std::cout << (*myic1)(0.5) << std::endl;
	myic2 = [](double x){return 0.0;};
	mywave.set_BC_left(mbc_left);
	mywave.set_BC_right(mbc_right);
	mywave.set_IC1(myic1);
	mywave.set_IC2(myic2);
	mywave.set_a(1);
	mywave.set_xlimits(0.0,1.0);
	mywave.set_tlimits(0,2);
	mywave.set_hx(0.0025);
	mywave.set_ht(0.0005);
	mywave.solve();
	// mywave.save_data("solution.txt");
	// std::vector<double> t_time(10);
	// t_time[0] = 0.0;
	// t_time[1] = 2*0.005;
	// t_time[2] = 103*0.005;
	// t_time[3] = 138*0.005;
	// t_time[4] = 247*0.005;
	// t_time[5] = 567*0.005;
	// t_time[6] = 800*0.005;
	// t_time[7] = 990*0.005;
	// t_time[8] = 1016*0.005;
	// t_time[9] = 1045*0.005;
	mywave.draw_data("model4.gif", 2);
	// clock_t end_time = clock();
	// std::cout << "Running time is: " << static_cast<double>(end_time - start_time)/CLOCKS_PER_SEC*1000 << "ms\n";
	return 0;
}